package winterTest.day10;

import static org.junit.Assert.assertArrayEquals;

import java.util.Arrays;
import java.util.Comparator;

import org.junit.Test;

public class TestComparator {
	@Test
	public void test1() {
		int[] array = { 4, 4, 5, 3, 34, 23, 9 };
		Arrays.sort(array);
		System.out.println(Arrays.toString(array));
	}
	@Test
	public void test2() {
		 String [] array= {"aa","ab","bc","bb","acd"};
		 Arrays.sort(array);
		 System.out.println(Arrays.toString(array));
		 
	}
	@Test
	public void test3() {
		String [] array= {"aa","ab","bc","bb","acd"};
		Arrays.sort(array);
		Arrays.sort(array,new Comparator<String>() {
			@Override
			public int compare(String o1, String o2) {
				if(o1.length()>o2.length()) {
					return 1;
				}else if(o1.length()==o2.length()) {
					return 0;
				}else {
					return -1;
				}
			}		
		});
		System.out.println(Arrays.toString(array));
		
	}
}
